<template>
  <div>
    <el-form ref="form" :model="FRightEdit" label-width="80px">
      <el-form-item label="权限名称">
        <el-input v-model="FRightEdit.FRightName"></el-input>
      </el-form-item>
      <el-form-item label="权限类别">
        <el-input v-model="FRightEdit.FRightType" disabled></el-input>
      </el-form-item>
      <el-form-item label="命名空间">
        <el-input v-model="FRightEdit.FNamespace" disabled></el-input>
      </el-form-item>
      <el-form-item label="控制器">
        <el-input v-model="FRightEdit.FControllerName" disabled></el-input>
      </el-form-item>
      <el-form-item label="接口动作">
        <el-input v-model="FRightEdit.FActionName" disabled></el-input>
      </el-form-item>
      <el-form-item label="角色级别">
        <el-input v-model="FRightEdit.FActionRole" disabled></el-input>
      </el-form-item>
      <el-form-item label="使用权限">
        <el-input v-model="FRightEdit.FRightScope" disabled></el-input>
      </el-form-item>
    </el-form>
    <el-row justify="end">
      <el-button type="primary" @click="onSave" :disabled="!zIsOpenData"
        >保存</el-button
      >
      <el-button type="warning" @click="onCancel">取消</el-button>
    </el-row>
  </div>
</template>

<script lang="ts">
import { TBaseRight } from "@/baselib/right/BaseRightClass";
import { Options, prop, Vue } from "vue-class-component";
import TFormBase from "@/views/BaseForm";
//配合着用
@Options({
  name: "TFormRightEdit",
  components: {},
  computed: {},
  data() {},
})
export default class TFormRightEdit extends TFormBase {
  private FRightID: string = "";
  private FRightEdit: TBaseRight = new TBaseRight();
  public async created() {
    this.FRightID = this.zContextParams.rightID;
    this.openData();
  }
  //打开数据
  public async openData() {
    if (!this.$myStrHelper.stringIsEmpty(this.FRightID)) {
      //打开数据
      this.zIsOpenData = false;
      let lResult = await this.$myBaseRightAPI.getRight(this.FRightID);
      if (!lResult.resultSuccess) {
        this.$myMsgHelp.msgDialog(lResult.resultMsg);
        return;
      }
      this.FRightEdit = lResult.resultData;
      if (this.$myStrHelper.stringIsEmptyYW(this.FRightEdit.FRightID)) {
        this.$myMsgHelp.msgDialog(
          "返回的数据结构有问题:" + JSON.stringify(lResult.resultData)
        );
        return;
      }
      this.zIsOpenData = true;
    } else {
      this.zIsOpenData = false;
      this.$myMsgHelp.msgDialog("权限ID为空");
    }
  }
  //
  private async onSave() {
    let lResult = await this.$myBaseRightAPI.saveRight(this.FRightEdit);
    if (!lResult.resultSuccess) {
      this.$myMsgHelp.msgDialog(lResult.resultMsg);
      return;
    }
    this.$myMsgHelp.msgHintAutoClose(
      "保存数据成功",
      this.$myMsgHelp.msgSuccess
    );
    if (this.zContextOnCall != null && this.zContextOnCall != undefined) {
      this.zContextOnCall("save", this.FRightEdit);
    }
  }
  private onCancel() {
    if (this.zContextOnCall != null && this.zContextOnCall != undefined) {
      this.zContextOnCall("close", this.FRightEdit);
    }
  }
}
</script>
<style>
</style>